package com.shisfish.english.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.shisfish.core.dto.ResultDto;
import com.shisfish.english.model.Category;
import com.shisfish.english.service.ICategoryService;
import com.shisfish.english.transform.ICategoryTransform;

@Service(value = "categoryService")
public class CategoryService implements ICategoryService {

	@Resource 
	ICategoryTransform categoryTransform;
	
	@Override
	public ResultDto<List<Category>> selectByParams(Long parent, String name) {
		List<Category> categoryList = categoryTransform.selectByParams(parent == null ? -1 : parent, name);
		if (categoryList == null || categoryList.size() == 0) 
			categoryList = new ArrayList<>();
		return new ResultDto<List<Category>>(categoryList);
	}

}
